﻿using System;
using System.Data;
using System.Linq;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void JLTWBZZM(DataSet db)
        {
            try
            {
                exAgent.SetCurrentSheet("JLTWBZZM");
                DataTable dtSoruce = db.Tables["WBZZM"];
                DataTable dtOutput = new DataTable();
                int idx = 1; 
                exAgent.SetCellValue(3, idx++, "月份"); dtOutput.Columns.Add("ZZMONTH", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "任务书"); dtOutput.Columns.Add("WBEWART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "小花号"); dtOutput.Columns.Add("WBEWFARBE", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "产品名称"); dtOutput.Columns.Add("ARTGRP", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "经纬密"); dtOutput.Columns.Add("WFDENSITY", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "经纬纱"); dtOutput.Columns.Add("CONSTRUCTION", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "总长度"); dtOutput.Columns.Add("TMTR", typeof(System.String)); 
                exAgent.SetCellValue(3, idx++, "一等"); dtOutput.Columns.Add("Q1", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "二等"); dtOutput.Columns.Add("Q2", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "三等"); dtOutput.Columns.Add("Q3", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "四等"); dtOutput.Columns.Add("Q4", typeof(System.String)); 
                dtOutput.Merge(dtSoruce, false, MissingSchemaAction.Ignore);
                foreach (DataRow row in dtOutput.Rows)
                {
                   /* row["GPPARTIE"] = GetGB2312Value(row["GPPARTIE"].ToString());
                    row["ABPFARBE"] = GetGB2312Value(row["ABPFARBE"].ToString());
                    row["X050"] = GetGB2312Value(row["X050"].ToString());*/
                }
                exAgent.DataTableToExcel(dtOutput, 4, 1);

                int count = dtOutput.Rows.Count;
                exAgent.SetCellValue(1, 1, 1); 
                exAgent.BatchConvert2Number(4, 7, count + 3, 11); 
                exAgent.SetCellValue(1, 1, "织造车间"+dtOutput.Rows[0]["ZZMONTH"].ToString()+"月份下机产质量汇总表");
                exAgent.RenameSheet(dtOutput.Rows[0]["ZZMONTH"].ToString());
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        
    }
}